<?php

namespace app\store\service;

use app\store\model\Article;

class ArticleService
{

    public function getArticleList($param)
    {   
        $store_id = session('store_id');

        $query =  Article::withOutField('article_cover,content,delete_time')->where('store_id',$store_id);

        if (!empty($param['cid'])){
            $query->where('article_category_id',"{$param['cid']}");
        }

        if (isset($param['status']) and $param['status'] != ''){
            $query->where('status',"{$param['status']}");
        }

        if (!empty($param['keyword'])){
           $query->whereLike('article_title',"%{$param['keyword']}%");
        }

        $articles = $query->paginate(10);
        
        return  $articles;
        
    }


    public function findArticle($id)
    {
        $article = Article::withOutField('create_time,update_time,delete_time')->find($id);
    
        
        return  $article;
        
    }

    
}